using System;
using System.ComponentModel;
using System.Collections.Generic;

using Castle.ActiveRecord;

/// <summary>
/// Business entity class generated from Repository
/// </summary>
/// <remarks>
/// Created by: huanhvhd
/// Created date: [2011-04-23]
/// </remarks>
namespace TVN.ShopMan.ActiveModels
{
	[ActiveRecord("Repository")]
	public partial class Repository : ActiveRecordBase<Repository>
	{
		#region Properties
		
        /// <summary>
        /// All properties
        /// </summary>
		public class Properties
		{
			public const string Id = "Id";
			public const string Name = "Name";
			public const string Address = "Address";
			public const string Email = "Email";
			public const string IsActive = "IsActive";
			public const string StartDate = "StartDate";
			public const string CreatedDate = "CreatedDate";
			public const string LastModifiedDate = "LastModifiedDate";
			public const string Creator = "Creator";
			public const string LastModifier = "LastModifier";
			public const string Owner = "Owner";
		}

		#endregion

		#region Private fields

		private int _id;
		private string _name;
		private string _address;
		private string _email;
		private bool _isActive;
		private DateTime _startDate;
		private DateTime _createdDate;
		private DateTime? _lastModifiedDate;
		private Account _creatorId;
		private Account _lastModifierId;
		private Account _ownerId;

		private IList<AccountRepository> _accountRepositoriesRepositoryId = new List<AccountRepository>();
		private IList<OrderSummary> _orderSummariesRepositoryId = new List<OrderSummary>();
		private IList<ProductRepository> _productRepositoriesRepositoryId = new List<ProductRepository>();
		private IList<RepositoryPhoneNumber> _repositoryPhoneNumbersRepositoryId = new List<RepositoryPhoneNumber>();

		#endregion

		#region Constructors

		public Repository()
		{
		}

		#endregion

		#region Properties

		[PrimaryKey("Id", Access = PropertyAccess.NosetterLowercaseUnderscore)]
		public int Id
		{
			get { return _id; }
		}

		[Property("Name", NotNull = true, Length = 256)]
		public string Name
		{
			get { return _name; }
			set { _name = value; }
		}

		[Property("Address", NotNull = true, Length = 512)]
		public string Address
		{
			get { return _address; }
			set { _address = value; }
		}

		[Property("Email", Length = 256)]
		public string Email
		{
			get { return _email; }
			set { _email = value; }
		}

		[Property("IsActive", NotNull = true)]
		public bool IsActive
		{
			get { return _isActive; }
			set { _isActive = value; }
		}

		[Property("StartDate", NotNull = true)]
		public DateTime StartDate
		{
			get { return _startDate; }
			set { _startDate = value; }
		}

		[Property("CreatedDate", NotNull = true)]
		public DateTime CreatedDate
		{
			get { return _createdDate; }
			set { _createdDate = value; }
		}

		[Property("LastModifiedDate")]
		public DateTime? LastModifiedDate
		{
			get { return _lastModifiedDate; }
			set { _lastModifiedDate = value; }
		}

		[BelongsTo("CreatorId", Type = typeof(Account))]
		public Account Creator
		{
			get { return _creatorId; }
			set { _creatorId = value; }
		}

		[BelongsTo("LastModifierId", Type = typeof(Account))]
		public Account LastModifier
		{
			get { return _lastModifierId; }
			set { _lastModifierId = value; }
		}

		[BelongsTo("OwnerId", Type = typeof(Account))]
		public Account Owner
		{
			get { return _ownerId; }
			set { _ownerId = value; }
		}

		[HasMany(typeof(AccountRepository), Table="AccountRepository", ColumnKey="RepositoryId")]
		public IList<AccountRepository> AccountRepositoriesRepositoryId
		{
			get { return _accountRepositoriesRepositoryId; }
			set { _accountRepositoriesRepositoryId = value; }
		}
		[HasMany(typeof(OrderSummary), Table="OrderSummary", ColumnKey="RepositoryId")]
		public IList<OrderSummary> OrderSummariesRepositoryId
		{
			get { return _orderSummariesRepositoryId; }
			set { _orderSummariesRepositoryId = value; }
		}
		[HasMany(typeof(ProductRepository), Table="ProductRepository", ColumnKey="RepositoryId")]
		public IList<ProductRepository> ProductRepositoriesRepositoryId
		{
			get { return _productRepositoriesRepositoryId; }
			set { _productRepositoriesRepositoryId = value; }
		}
		[HasMany(typeof(RepositoryPhoneNumber), Table="RepositoryPhoneNumber", ColumnKey="RepositoryId")]
		public IList<RepositoryPhoneNumber> RepositoryPhoneNumbersRepositoryId
		{
			get { return _repositoryPhoneNumbersRepositoryId; }
			set { _repositoryPhoneNumbersRepositoryId = value; }
		}
		#endregion

	} }
